/*********************************************************************
*
*   Joystick.cpp - Joystick class
*
*   Copyright:
*       Software source code by Alex Morozov and Chris D. Locke is
*       licensed under a Creative Commons Attribution-Noncommercial-
*       Share Alike 3.0 United States License
*       (http://creativecommons.org/licenses/by-nc-sa/3.0/us/)
*
*********************************************************************/

#include "StdAfx.h"
#include "CppBot_types.h"
#include "Joystick.h"
#include "CppBot.h"

/*********************************************************************
*
*       Joystick - Constructor
*
*********************************************************************/

Joystick::Joystick( UINT32 port ) : m_port( port )
{
}


/*********************************************************************
*
*       ~Joystick - Destructor
*
*********************************************************************/

Joystick::~Joystick(void)
{
}


/*********************************************************************
*
*       GetX - Get x position
*
*********************************************************************/

float Joystick::GetX( JoystickHand hand )
{
int                     val;

get_joy( 0, &val, NULL );
return( ( float )val / 100.0f );    //return -1.0 to 1.0
}


/*********************************************************************
*
*       GetX - Get y position
*
*********************************************************************/

float Joystick::GetY( JoystickHand hand )
{
int                     val;

get_joy( 0, NULL, &val );
return( ( float )val / 100.0f );    //return -1.0 to 1.0
}
